﻿/*******************************************************************************
 * Copyright © 2016-2020 北京网非科技有限公司 版权所有
 * Author: 北京网非科技有限公司
 * Description: 网非快速开发平台NET
 * Website：http://www.wfdot.com
*********************************************************************************/
using CubicFWNet.Application.SystemManage;
using CubicFWNet.Mvc.Filter;
using CubicFWNet.Mvc.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CubicFWNet.Common;
using CubicFWNet.Application.SystemSecurity;
using Webdiyer.WebControls.Mvc;
using CubicFWNet.Data.SystemSecurity.Model;

namespace CubicFWNet.Mvc.Areas.SystemSecurity.Controllers
{
    public class LogInLogController : ControllerBase
    {
        private LogApp _logApp;
        public LogInLogController()
        {
            _logApp = new LogApp();
        }
        //[Authenticate]
        [HttpGet]
        public ActionResult Index(string dateType="week", string keyWord = "", int id = 1)
        {            
            int pageSize = Application.UserProfile.GetPageSize(this.CurrentUserId);
            var result = _logApp.Get(keyWord, dateType).ToPagedList<LogInLog>(id, pageSize);
            if (Request.IsAjaxRequest())
            {
               // System.Threading.Thread.Sleep(20000);  //用于测试加载特效
                return PartialView("_AjaxLogInLogTable", result);
            }                
            return View(result);
        }
        [Delete]
        [HttpPost]
        [HandlerAjaxOnly]
        public string SubmitRemoveLog(string keepTime)
        {
            try
            {
                _logApp.RemoveLog(keepTime);
            }
            catch (Exception ex)
            {
                Result.Status = "error";
                Result.Message = "系统异常，请联系管理员";
            }
            Result.Data = keepTime;
            return Result.ToJson();
        }
    }
}